package com.example.administrator.demorecyclerview.refresh;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

/**
 * Created by ionca on 2018/2/4.
 */
@CoordinatorLayout.DefaultBehavior(MyAppBarLayout.MyBehavior.class)
public class MyAppBarLayout extends AppBarLayout {
    public MyAppBarLayout(Context context) {
        super(context);
    }

    public MyAppBarLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    public static class MyBehavior extends Behavior {

        @Override
        public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout abl, View target, int type) {
            super.onStopNestedScroll(coordinatorLayout, abl, target, type);

        }

        @Override
        public boolean onInterceptTouchEvent(CoordinatorLayout parent, AppBarLayout child, MotionEvent ev) {
            return super.onInterceptTouchEvent(parent, child, ev);
        }

        @Override
        public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dx, int dy, int[] consumed, int type) {
            super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
//            Log.i("@@@@@@@@@","@@@@@@@@@@@onNestedPreScroll");
        }


        @Override
        public void onNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) {
            super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
//            Log.i("@@@@@@@@@","@@@@@@@@@@@onNestedScroll");
        }


        @Override
        public boolean onNestedPreFling(@NonNull CoordinatorLayout coordinatorLayout, @NonNull AppBarLayout child, @NonNull View target, float velocityX, float velocityY) {
//            Log.i("@@@@@@@@@","@@@@@@@@@@@onNestedPreFling");

            return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
        }

        @Override
        public boolean onNestedFling(@NonNull CoordinatorLayout coordinatorLayout, @NonNull AppBarLayout child, @NonNull View target, float velocityX, float velocityY, boolean consumed) {
//            Log.i("@@@@@@@@@","@@@@@@@@@@@onNestedFling");

            return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
        }
    }
}
